package com.huluobo.jetpackkotlindemo.viewbinding

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.huluobo.jetpackkotlindemo.databinding.FragmentMainBinding

/**
 * Created by lc on 2022/12/8.
 * Fragment如何去使用ViewBinding
 */
class MainFragment : Fragment() {
    private var fragmentMainBinding: FragmentMainBinding? = null
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        fragmentMainBinding = FragmentMainBinding.inflate(inflater, container, false)
        return fragmentMainBinding?.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        fragmentMainBinding?.btnContent?.setOnClickListener {

        }
        fragmentMainBinding?.edContent?.setText("123")
    }

    override fun onDestroy() {
        super.onDestroy()
        fragmentMainBinding = null
    }
}